package solutions.csdn

class test {
}

fun main() {
    val str = "W型滚刷100400263\n" +
            "物美蓝色胶皮（前）100400397\n" +
            "物美蓝色胶皮（后）100400398\n" +
            "吸水扒前胶皮（红色）A0304020332\n" +
            "吸水扒后胶皮（红色）A0304020333\n" +
            "尼龙滤网过滤袋A0607010050\n" +
            "左侧滚刷端盖A0309000146A\n" +
            "右侧滚刷端盖A0309000147A\n" +
            "75老款胶皮（前）A0303010533\n" +
            "75老款胶皮（后）A0303010534\n" +
            "75新款胶皮（前）A0304020543\n" +
            "75新款胶皮（后）A0304020544\n" +
            "3.6-3.7钢丝过滤网A0306010004\n" +
            "4.04-4.1钢丝过滤网101300014\n" +
            "塞打螺丝\n" +
            "A0301011403\n" +
            "聚氨酯成型轴承\n" +
            "A0301040310\n" +
            "分度销拉丝扣A0301070676\n"
    val part = str.split('\n')
    val sb = StringBuilder("=")
    fillSB(sb, part, 0)
    println(sb)
}

fun fillSB(sb: StringBuilder, part: List<String>, i: Int) {
    if (i >= part.size) {
        sb.append("\"\"")
        return
    }
    sb.append(part1).append(i + 3).append(part2)
    fillSB(sb, part, i + 1)
    sb.append(part3)
}

val part1 = "IF(ISNUMBER(SEARCH(\""
val part2 = "\",J2)),VLOOKUP(E2,Sheet1!M:AE,18,FALSE),"
val part3 = ")"